{% extends "base.html" %}
{% load i18n %}

{% block block_title %} Program list {% endblock %}

{% block breadcrumb %}
    {{ block.super }} &raquo; {% trans 'Regions' %}
    <a href="#url-to-program_new" class="form-tooltip" id="show-form">{% trans 'Add region' %}</a>
{% endblock %}

{% block system_messages %}
    <div class="messages">
        {% for msg in system_messages %}
        <div class="message {{ msg.type }}"><p>{{ msg.message }}</p></div>
        {% endfor %}
    </div>
{% endblock %}

{% block block_content %}
    <div class="block new-item-form" id="new-item-form">
        <div class="block_head">
            <div class="bheadl"></div>
            <div class="bheadr"></div>

            <h2>{% trans 'Add region' %}</h2>
        </div>
        <div class="block_content">
            <form action="{% url new_region %}" method="post">
                {% csrf_token %}
                <label>
                    {% trans 'Region name' %}:<br />
                    {{ region_form.region_name }}
                </label>
                <input type="submit" name="add_program" class="submit mid add-button" value="{% trans 'Add' %}" />
            </form>
        </div>
        <div class="bendl"></div>
        <div class="bendr"></div>
    </div>
    {% if regions|length %}
    <form action="{% url list_regions %}" method="post">

        <table cellpadding="0" cellspacing="0" width="100%" class="sortable">
            <thead>
                <tr>
                    <th width="10"><input type="checkbox" class="check_all" /></th>
                    <th>{% trans 'Region' %}</th>
                    <td>&nbsp;</td>
                </tr>
            </thead>

            <tbody>
            {% for region in regions %}
                <tr>
                    <td>
                        <input type="checkbox" value="{{ region.id }}" />
                    </td>
                    <td>
                        <a href="#">{{ region.region_name }}</a>
                    </td>
                    <td class="delete">
                        <a href="{% url update_region region.id %}">{%  trans 'Edit' %}</a>
                        |
                        <a href="{% url delete_region region.id %}">{%  trans 'Delete' %}</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>

        <div class="tableactions">

                <select>
                    <option>Actions</option>
                    <option>Delete</option>
                </select>

            <input type="submit" class="submit tiny" value="Apply to selected" />
        </div>		<!-- .tableactions ends -->

        {% if is_paginated %}
        <div class="pagination right">
            <span class="page-links">
            {% if page_obj.has_previous %}
            <a href="{% url list_regions %}?page= {{ page_obj.previous_page_number }}">previous</a>
            {% endif %}
            <span class="page-current">
                Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
            </span>
            {% if page_obj.has_next %}
            <a href="{% url list_regions %}?page={{ page_obj.next_page_number }}">next</a>
            {% endif %}
            </span>
        </div>      <!-- .pagination ends -->
        {% endif %}

    </form>
    {% else %}
        {% trans 'No regions found' %}
    {% endif %}
{% endblock %}

{% block scripts %}
    <script type="text/javascript" src="/static/js/lira.js"></script>
{% endblock %}
